package com.tihi.treeview;

import android.content.Context;
import android.media.Image;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.github.johnkil.print.PrintView;
import com.tihi.handsuiviewer.R;
import com.tihi.xml.ViewNode;
import com.unnamed.b.atv.model.TreeNode;

/**
 * Created by Bogdan Melnychuk on 2/13/15.
 */
public class UITreeHolder extends TreeNode.BaseNodeViewHolder<UITreeHolder.UITreeData> {
	
	public static class UITreeData {
		String text;
		ViewNode viewNode;
		
		public UITreeData(String text, ViewNode viewNode) {
			this.text = text;
			this.viewNode = viewNode;
		}

		public String getText() {
			return text;
		}

		public void setText(String text) {
			this.text = text;
		}

		public ViewNode getViewNode() {
			return viewNode;
		}

		public void setViewNode(ViewNode viewNode) {
			this.viewNode = viewNode;
		}
	}

    public UITreeHolder(Context context) {
        super(context);
    }

    private ImageView arrowView;
    @Override
    public View createNodeView(TreeNode node, UITreeHolder.UITreeData value) {
        final LayoutInflater inflater = LayoutInflater.from(context);
        final View view = inflater.inflate(R.layout.layout_profile_node, null, false);
        TextView tvValue = (TextView) view.findViewById(R.id.node_value);
        tvValue.setText(value.text);

        arrowView = (ImageView) view.findViewById(R.id.arrow_icon);
        return view;
    }

    @Override
    public void toggle(boolean active) {
    	arrowView.setImageResource(active ? R.drawable.down : R.drawable.right);
//        arrowView.setIconText(context.getResources().getString(active ? R.string.ic_keyboard_arrow_down : R.string.ic_keyboard_arrow_right));
    }

    @Override
    public int getContainerStyle() {
        return R.style.TreeNodeStyleCustom;
    }
}
